<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%response.setHeader("cache-control","public"); %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/style.default.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap-table.css">
    <script src="<%=path %>/js/respond.js"></script>
    <style>
        .jfph_title td {
            padding: 8px 5px !important;
            display: block;
            font-size: 16px !important;
            line-height: 30px;
            float: left;
        }

        .jfph_more {
            display: block;
            line-height: 30px;
            cursor: pointer;
            text-decoration: underline;
            text-align: center !important;
        }
    </style>

</head>
<body>
<!--head begin-->

<jsp:include page="head.jsp" flush="true"/>

<div class="container body-box jfph_main">
    <table class="table jfph_title" cellpadding="0" cellspacing="0">
        <tr>
            <td width="44%" align="right"><img src="<%=path%>/static/images/jfph_title.png"></td>
            <td width="56%" align="left">得分排行</td>
        </tr>
    </table>
    <table id="table"></table>
    <div class="jfph_ling"></div>
    <div id="jfph_more">

        <img class="jfph_loading" style="display: none;" src="<%=path%>/static/images/loading.gif">
    </div>
    <script type="text/javascript">
    </script>
</div>
<!--body end-->

<!--footer begin-->

</body>
<!--footer end-->
<script type="text/javascript" src="<%=path%>/static/jquery/jquery-1.12.2.min.js">
</script>
<script type="text/javascript" src="<%=path%>/static/js/bootstrap-table.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/js/bootstrap-table-zh-CN.js"></script>

<script type="text/javascript">
    //考试管理主页面
    if (${role eq 'master'}) {
        $('#topMain').children().eq(0).addClass('active'); // 追加样式;
        $('#topMain').children().eq(0).children().attr('href', '#');
    } else if (${role eq 'trainee'}) {
        $('#topMain').children().eq(0).addClass('active'); // 追加样式;
        $('#topMain').children().eq(0).children().attr('href', '#');
    } else {
        $('#topMain').children().eq(5).addClass('active'); // 追加样式;
        $('#topMain').children().eq(5).children().attr('href', '#');
    }
    $('#table').bootstrapTable({
        "pagination": true,
        "search": true,
        method: 'post',
        dataType: 'json',
        contentType: "application/x-www-form-urlencoded",
        url: '<%=basePath %>examCenter/queryResultsDataList?examid=' +${examid},
        toolbar: "#toolbar",
        showHeader: true,
        //是否启用排序
        sortable: true,
        //排序方式
        sortOrder: "desc",
        pageNumber: 1,
        showRefresh: true, //是否显示刷新按钮
        pageSize: 5, //每页的记录行数（*）
        pageList: [5, 10, 15, 20], //可供选择的每页的行数（*）
        clickToSelect: true, //是否启用点击选中行
        columns: [{
            field: 'number',
            title: '名次',
            align: "center",
            formatter: function (value, row, index) {
                if (index == 0) {
                    return '<img  src="<%=path%>/static/images/jfph_st.png" >' + ' 1';
                } else if (index == 1) {
                    return '<img  src="<%=path%>/static/images/jfph_nd.png" >' + ' 2';
                } else if (index == 2) {
                    return '<img  src="<%=path%>/static/images/jfph_rd.png" >' + ' 3';
                }
                return index + 1;
            }
        }, {
            field: 'extend',
            title: '姓名',
            align: "center"
        }, {
            field: 'test_number',
            title: '准考证号',
            align: "center"
        }, {
            field: 'score',
            title: '成绩',
            align: "center"
        }],
        onClickRow: function (row) {
            var myForm = document.createElement("form");
            myForm.method = "post";
            myForm.action = "<%=basePath %>examCenter/queryUserPaperResults";
            var examid = document.createElement("input");
            examid.setAttribute("name", "examid");  // 为input对象设置name
            examid.setAttribute("value", row.exam_id);  // 为input对象设置value
            myForm.appendChild(examid);
            var paperid = document.createElement("input");
            paperid.setAttribute("name", "paperid");  // 为input对象设置name
            paperid.setAttribute("value", "");  // 为input对象设置value
            myForm.appendChild(paperid);
            var studentid = document.createElement("input");
            studentid.setAttribute("name", "studentid");  // 为input对象设置name
            studentid.setAttribute("value", row.user_id);  // 为input对象设置value
            myForm.appendChild(studentid);

            var studentName = document.createElement("input");
            studentName.setAttribute("name", "studentName");  // 为input对象设置name
            studentName.setAttribute("value", row.extend);  // 为input对象设置value
            myForm.appendChild(studentName);

            var score = document.createElement("input");
            score.setAttribute("name", "score");  // 为input对象设置name
            score.setAttribute("value", row.score);  // 为input对象设置value
            myForm.appendChild(score);
            document.body.appendChild(myForm);
            myForm.submit();
            document.body.removeChild(myForm);  // 提交后移除创建的form
        }
    });

</script>
</html>